const { log } = require('console')
const http = require('http')

const server = http.createServer()

server.on('request', (req, res) => {
  //请求的url地址
  const url = req.url
  // 请求的method类型
  const method = req.method
  // const str = `dizhi is ${url}, method is ${method}`
  const str = `您请求的地址是${url}, 请求方法是${method}`
  res.setHeader('Content-Type', 'text/html; charset=utf-8')
  // console.log(str)
  //调用res.end()方法，向客户端响应一些内容
  res.end(str)
  
})

server.listen(80, () => {
  console.log('server running at http://127.0.0.1')
  
})